package study.transactionStudy.controller;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.core.JsonEncoding;
import com.fasterxml.jackson.core.JsonFactory;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import study.transactionStudy.dao.CustomerRepository;
import study.transactionStudy.domain.Customer;
import study.transactionStudy.service.CustomerServiceTxInAnnotation;

/**
 * @author jiangfeng 2019/7/9 12:47
 */
@Slf4j
@RequestMapping(value = "/customer")
@RestController
public class CustomerController {

    @Autowired
    CustomerRepository customerRepository;

    @Autowired
    CustomerServiceTxInAnnotation customerService;


    @PostMapping("/annotation")
    public Customer createInAnnotation(@RequestBody Customer customer) {
        log.info("11111111 customer:{}", customer);
        Customer customer1 = customerService.create(customer);

        return customer1;
    }

    @GetMapping(value = "/getAll")
    public List getAll(){
        List<Customer> all = customerRepository.findAll();
        return all;
    }

}
